The first character in a string is at index 0.
def slice1(s):
c = s[0]
return c
Function Call | Return Value | |||
---|---|---|---|---|
slice1('Car') | → | |||
slice1('Truck') | → | |||
slice1('55684') | → | |||
slice1('Elephant') | → | |||
slice1('Roses') | → |
Experiment with this code on Gitpod.io